import 'package:finance_app/src/entities/tax_submission_detail_entity.dart';
import 'package:finance_app/src/utils/date_time_utils.dart';

taxSubmissionDetailEntityFromJson(TaxSubmissionDetailEntity data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['start_date'] != null) {
		data.startDate = json['start_date'].toString();
	}
	if (json['end_date'] != null) {
		data.endDate = json['end_date'].toString();
	}
	if (json['lines'] != null) {
		data.lines = (json['lines'] as List).map((v) => TaxSubmissionDetailTaxSubmissionLines().fromJson(v)).toList();
	}
	if (json['status'] != null) {
		data.status = json['status'].toString();
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	if (json['year_of_assessment'] != null) {
		data.yearOfAssessment = json['year_of_assessment'];
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	return data;
}

Map<String, dynamic> taxSubmissionDetailEntityToJson(TaxSubmissionDetailEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['start_date'] = entity.startDate;
	data['end_date'] = entity.endDate;
	data['lines'] =  entity.lines?.map((v) => v.toJson())?.toList();
	data['status'] = entity.status;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	data['year_of_assessment'] = entity.yearOfAssessment;
	data['type'] = entity.type;
	return data;
}

taxSubmissionDetailTaxSubmissionLinesFromJson(TaxSubmissionDetailTaxSubmissionLines data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['company_id'] != null) {
		data.companyId = json['company_id'] is String
				? int.tryParse(json['company_id'])
				: json['company_id'].toInt();
	}
	if (json['tax_submission_id'] != null) {
		data.taxSubmissionId = json['tax_submission_id'] is String
				? int.tryParse(json['tax_submission_id'])
				: json['tax_submission_id'].toInt();
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['line'] != null) {
		data.line = json['line'] is String
				? int.tryParse(json['line'])
				: json['line'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['amount'] != null) {
		data.amount = json['amount'] is String
				? num.tryParse(json['amount'])
				: json['amount'];
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	return data;
}

Map<String, dynamic> taxSubmissionDetailTaxSubmissionLinesToJson(TaxSubmissionDetailTaxSubmissionLines entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['company_id'] = entity.companyId;
	data['tax_submission_id'] = entity.taxSubmissionId;
	data['key'] = entity.key;
	data['line'] = entity.line;
	data['name'] = entity.name;
	data['amount'] = entity.amount;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	return data;
}